import { createSlice } from '@reduxjs/toolkit'

interface IAppState  {
  collapsed: boolean
}
// const initialState: IAppState = {
//   collapsed: false
// }
const initialState = {
  // collapsed: false
  collapsed: localStorage.getItem('collapsed') === 'true'
} as IAppState

export const appSlice = createSlice({
  name: 'app',
  initialState, 
  reducers: {
    changeCollapsed (state) {
      state.collapsed = !state.collapsed
    }
  }
})

export const { changeCollapsed } = appSlice.actions

export default appSlice.reducer